<form action="php/p_edit_assumed.php" method="POST" data-ajax="false" enctype="multipart/form-data" >
    <input type="hidden" name="p_nr" value="<?php echo $project_nr; ?>" />
    <input type="hidden" name="p_client_id" value="<?php echo $client_id; ?>" />
    <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
        <li class="ui-li ui-li-static ui-body-c ui-corner-top">
            <table align="center">
                <tr>
                    <td><h3 style="color:orange">Allgemein:</h3></td>
                    <td width="10px"></td>
                    <td></td>
                </tr>
                <tr>
                    <td valign="top"><b>Projektname:</b></td>
                    <td width="10px"></td>
                    <td><?php echo $data['p_name']; ?></td>
                </tr>
                <tr>
                    <td valign="top"><b>Projekt-Ort:</b></td>
                    <td width="10px"></td>
                    <td><?php echo $data['city']; ?></td>
                </tr>
                <tr>
                    <td valign="top"><b>Auftraggeber:</b></td>
                    <td width="10px"></td>
                    <td><?php echo $data['name']; ?></td>
                </tr>
                <tr>
                    <td><h3 style="color:orange">Datum:</h3></td>
                    <td width="10px"></td>
                    <td></td>
                </tr>
                <tr>
                    <td><b>Anfrage:</b></td>
                    <td width="10px"></td>
                    <td>
                        <?php
                            $datearray = explode('-', $data['date_inquiry']);
                            echo $datearray[2].'.'.$datearray[1].'.'.$datearray[0];
                        ?>
                    </td>
                </tr>
                <tr>
                    <td><b>Angebot:</b></td>
                    <td width="10px"></td>
                    <td>
                        <?php
                            $datearray = explode('-', $data['date_offer']);
                            echo $datearray[2].'.'.$datearray[1].'.'.$datearray[0];
                        ?>
                    </td>
                </tr>
            </table>
        </li>
    </ul>
    <h3>Bestelldatum</h3>
    <input type="date" id="p_date_order" name="p_date_order" value="<?php echo $data['date_order']; ?>" />
    <h3>Bestellsumme in &euro;</h3>
    <input type="text" id="p_order_sum" name="p_order_sum" value="<?php echo $data['order_sum']; ?>" />
    <h3>Bestellnr. <font style="color:#2666db"><?php echo $data['name']; ?></font></h3>
    <input type="text" id="order_nr_client" name="order_nr_client" value="<?php echo $data['order_nr_client']; ?>" />
    <h3>Projektnr. <font style="color:#2666db"><?php echo $data['name']; ?></font></h3>
    <input type="text" id="p_nr_client" name="p_nr_client" value="<?php echo $data['project_nr_client']; ?>" />
    <h3>Anschrift Baustelle</h3>
    <div data-role="fieldcontain">
        <label for="p_street">Straße:</label>
        <input type="text" name="p_street" id="p_street" value="<?php echo $data['street']; ?>" placeholder="Stra&szlig;e" />
        <label for="p_zip">Postleitzahl:</label>
        <input type="tel" name="p_zip" id="p_zip" value="<?php echo $data['zip']; ?>" placeholder="Postleitzahl" />
        <label for="p_city">Ort:</label>
        <input type="text" name="p_city" id="p_city" value="<?php echo $data['city']; ?>" placeholder="Ort *" />
    </div>
    <h3>Bemerkung</h3>
    <textarea placeholder="Kommentar eintragen!" name="p_comment"><?php echo $data['comment']; ?></textarea>
    <h3>Dateien</h3>
    <input type="file" name="file" />
    <input tpye="text" name="alias" placeholder="Datei Alias" id="alias" /
    <br /><br />
    <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
            <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                <div align="center">
                    <?php
                        $sql = "SELECT * FROM file WHERE pid = '" . $project_nr . "'";
                        $resultFile = mysql_query($sql);

                        if (mysql_num_fields($resultFile) > 0) {
                            $dir = '../assets/uploads/'.$project_nr;
                    ?>
                        <table>
                            <tr>
                                <td><b>Dateilink</b></td>
                                <td width="10px"></td>
                                <td><b>Alias</b></td>
                            </tr>
                            <tr height="5px"></tr>
                    <?php
                            while ($dataFile = mysql_fetch_array($resultFile)) {
                    ?>
                            <tr>
                                <td align="left"><b>
                                        <a href="<?php echo $dir . '/' . $dataFile['file']; ?>" target="_blank" data-role="button" data-icon="grid" data-theme="e" data-iconpos="notext">Datei</a>
                                    </b></td>
                                <td></td>
                                <td><b><?php
                                    if (strlen($dataFile['alias']) <= 20) {
                                        echo $dataFile['alias'];
                                    } else {
                                        echo substr($dataFile['alias'], 0,20) . '...';
                                    }
                                ?></b></td>
                            </tr>
                    <?php
                            }
                    ?>
                        </table>
                    <?php
                        }
                    ?>
            </div>
        </li>
    </ul>
    <?php

        $sql = "SELECT * FROM project_manager WHERE pm_id = '" . $data['pm_id'] . "'";
        $result = mysql_query($sql);

        if (mysql_num_rows($result) > 0) {
            $datapminfo = mysql_fetch_array($result);
    ?>
        <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
            <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                <div align="center">
                    <h3 style="color:orange">Ihr zuständiger Projektleiter: </h3>
                    <h3><?php echo $datapminfo['vorname'] . ' ' . $datapminfo['name']; ?></h3>
                    <table>
                        <tr>
                            <td><b>Telefon:</b></td>
                            <td width="10px"></td>
                            <td><a href="tel:<?php echo $datapminfo['phone']; ?>"><?php echo $datapminfo['phone']; ?></a></td>
                        </tr>
                        <tr>
                            <td><b>Email:</b></td>
                            <td width="10px"></td>
                            <td><a href="mailto:<?php echo $datapminfo['email']; ?>"><?php echo $datapminfo['email']; ?></a></td>
                        </tr>
                        <tr>
                            <td><b>Mobil:</b></td>
                            <td width="10px"></td>
                            <td><a href="tel:<?php echo $datapminfo['mobil']; ?>"><?php echo $datapminfo['mobil']; ?></a></td>
                        </tr>
                    </table>
                </div>
            </li>
        </ul>
    <input type="hidden" name="p_pm_list" value="<?php echo $datapminfo['pm_id']; ?>" />
    <?php
        } else {
    ?>
        <h3>Projektleiter des Auftraggebers</h3>
        <label for="p_pm" class="select ui-hidden-accessible">Projektleiter:</label>
        <div id="p_km">
            <select name="p_pm_list" id="p_pm_list" data-native-menu="false">
                <option value="new">Neuer Projektleiter</option>
            <?php
                $sql = "SELECT * FROM project_manager WHERE client_id = " . $client_id . " AND km_or_pm = 'pm'";
                $result = mysql_query($sql);

                if (mysql_num_rows($result) > 0) {
                    while ($datapm = mysql_fetch_array($result)) {
            ?>
                        <option value="<?php echo $datapm['pm_id']; ?>"><?php echo $datapm['vorname'] . " " . $datapm['name']; ?></option>
            <?php
                    }
                } else {
            ?>
                    <option value="no">Keine Projektleiter vorhanden</option>
            <?php
                }
            ?>
            </select>
        </div>
        <div id="new_pm">
            <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
                <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                    <table align="center">
                        <tr>
                            <td style="vertical-align: middle">
                                <img src="../assets/images/alert.png" width="34px" />
                            </td>
                            <td width="20px"></td>
                            <td style="vertical-align: middle">
                                Folgende Felder m&uuml;ssen nur ausgef&uuml;llt werden, wenn <font style="color:green">
                                "Neuer Projektleiter"</font> ausgew&auml;hlt ist, ansonsten werden diese Felder ignoriert!
                            </td>
                        </tr>
                    </table>
                </li>
            </ul>
            <h4>Neuer Projektleiter:</h4>
            <input id="pm_name" type="text" name="pm_name" placeholder="Name *" />
            <input id="pm_vorname" type="text" name="pm_vorname" placeholder="Vorname" />
            <input id="pm_phone" type="tel" name="pm_phone" placeholder="Telefon" />
            <input id="pm_email" type="email" name="pm_email" placeholder="E-Mail" />
            <input id="pm_mobil" type="tel" name="pm_mobil" placeholder="Mobil" />
        </div>
    <?php
        }
    ?>
    <br />
    <select name="status_choose" id="status_choose" data-native-menu="false">
        <option value="0">Noch offen</option>
        <option value="1" selected="true">Auftrag</option>
        <option value="4">Zurückgestellt</option>
        <option value="2">Kein Auftrag</option>
        <option value="3">Auftrag & Erledigt</option>
    </select>
    <br />
    <button type="submit" data-theme="e">Änderung speichern</button>
</form>
